Add JMH benchmark harness - #3
Merged
Merged
Conversation
Measures the publish -> consume -> acknowledge round trip as throughput and as a latency distribution, across payload size and durability mode, plus a contended multi-threaded variant. The round trip is the unit of work rather than a bare publish: publishing without consuming grows the queue without bound, so a long run would measure allocation pressure instead of queue behaviour. Two notes on the build. JDK 23+ defaults to -proc:none, so proc=full is required or the annotation processor silently generates nothing. And JMH forks a JVM per trial, which exec:java cannot supply a usable classpath for, hence benchmarks.sh building one explicitly. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Merged
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The test suite proves the queue is correct. Nothing measured whether it is fast. This adds that.
What it measures
RoundTripBenchmark.throughputRoundTripBenchmark.latencyConcurrencyBenchmark.contendedRoundTripEarly results
Preliminary, short-run, on a single dev machine — the full suite will produce the real numbers.
Durability costs 32×. At 1 KB payloads:
memorywalWorth noting
WalWritercallsBufferedWriter.flush(), which reaches the OS page cache but neverfsyncs. So this 32× buys durability against process crash, not against power loss. A true fsync would cost considerably more.Concurrency scales negatively:
MessageQueueguards aLinkedListwith a single monitor, so four threads contend rather than parallelise. Publishing this as-is — it is an honest measurement and a concrete target for a later change.Build notes
Two non-obvious things, both commented in place:
<proc>full</proc>is required. JDK 23+ defaults to-proc:none; without it JMH's processor runs silently, emits noBenchmarkList, and the suite reports zero benchmarks with no error.exec:javacannot run JMH. It forks a JVM per trial, and Maven's classloader gives the fork no usablejava.class.path(ClassNotFoundException: ForkedMain).benchmarks.shresolves a real classpath instead.🤖 Generated with Claude Code